#ifndef EDGE_H
#define EDGE_H

#include <QGraphicsItem>
#include <QStaticText>
#include <QMessageBox>
#include <QGraphicsDropShadowEffect>

class Node;

// directed arrow
class Edge :  public QObject, public QGraphicsItem
{
Q_OBJECT
public:

    Edge(Node *sourceNode, Node *destNode);
    ~Edge();


    Node *sourceNode() const;
    Node *destNode() const;
    double angle() const;

    QString getTextEdge();
    void setTextEdge(QString text);

    // set/get color/width/secondary
    QColor color() const;
    void setColor(const QColor &color);
    qreal width() const;
    void setWidth(const qreal &width);
    bool secondary() const;
    void setSecondary(const bool &sec = true );
    void setBorder(const bool &hasBorder = true);

    // re-calculates the source and endpoint.
    // called when the source/dest node changed (size,pos)
    void adjust();
public slots:
    void setNameEdge(QString text);


protected:

    QRectF boundingRect() const;
    void paint(QPainter *painter,
               const QStyleOptionGraphicsItem *option,
               QWidget *widget);
    void mousePressEvent(QGraphicsSceneMouseEvent *event);

signals:
    void edgeSelected();
    void ssss();

private:

    Node *m_sourceNode;
    Node *m_destNode;

    QString m_textEdge;
    QPointF m_sourcePoint;
    QPointF m_destPoint;
    double m_angle;
    QColor m_color;
    qreal m_width;

    bool m_secondary;
    bool m_hasBorder;

    // just a logical connection between two nodes,
    // does not counts at subtree calculation


    static const qreal m_arrowSize;
    static const double m_pi;
    static const double m_twoPi;
};

#endif
